<template>
    <ul class="sidebar-menu" data-widget="tree">
        <li class="header">MAIN NAVIGATION</li>
        <li class="treeview">
            <a @click="noop">
                <i class="fa fa-dashboard"></i> <span>系统管理</span>
                <span class="pull-right-container">
                  <i class="fa fa-angle-left pull-right"></i>
                </span>
            </a>
            <ul class="treeview-menu">
                <li><a href="/admin/#/"><i class="fa fa-dashboard"></i> 仪表盘</a></li>
                <li><a href="/admin/users/#/"><i class="fa fa-user"></i> 用户管理</a></li>
            </ul>
        </li>
        <li><a href="/admin/news/#/"><i class="fa fa-tasks "></i> <span>内容管理</span></a></li>
    </ul>
</template>

<script>
    export default {
        mounted() {
            $('a[href]', this.$el).click(function() {
                $('.active').removeClass('active');
                $('.menu-open').removeClass('menu-open');
                $(this).parents('li').addClass('active').addClass('menu-open');
            });

            const url = window.location.pathname + window.location.hash;
            const $link = $(`a[href="${url}"]`, this.$el);
            $link.trigger('click');
        },
        methods: {
            noop() {return false;}
        }
    }
</script>
